package com.briup.web;

import com.briup.entity.Emp;
import com.briup.service.IEmpService;
import com.briup.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/emps")
public class EmpController {
    //业务层对象
    @Autowired
    private IEmpService empService;

    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Integer id) {
        System.out.println("in web, id: " + id);
        Emp emp = empService.getById(id);
        return Result.success(emp);
    }
    @GetMapping("/insert")
    public Result insert(Emp emp){
        return Result.success();
    }
    @GetMapping("/deleteById/{id}")
    public Result deleteById(@PathVariable Integer id){
        System.out.println("in web, id: " + id);
        empService.deleteById(id);
        return Result.success();
    }
    @GetMapping("/update")
    public Result update( Emp emp){
        System.out.println("in web, emp: " + emp);
        empService.update(emp);
        return Result.success();
    }
}
